package sliding_window

func maxArea(height []int) int {
	if len(height) > 0 {
		max, start, end := 0, 0, len(height)-1
		for start < end {
			width := end - start
			high := 0
			if height[start] < height[end] {
				high = height[start]
				start++
			} else {
				high = height[end]
				end--
			}

			tmp := width * high
			if tmp > max {
				max = tmp
			}
		}
		return max
	}
	return 0
}
